package com.example.controller;

import com.example.entity.SpPl;
import com.example.mapper.SpPlMapper;
import com.example.service.SpPlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

@RestController
@RequestMapping("/sp")
public class SpPlController {
    @Resource
    private SpPlService spPlService;
    @Autowired
    private SpPlMapper spPlMapper;


    @Autowired
    private Environment environment;

    @GetMapping("/a")
    public void adds() {
        System.out.println(environment.getProperty("app.SecretId"));
    }

    @PostMapping("/add")
    public Boolean add(@RequestBody SpPl spPl) {
        spPl.setCreateTime(LocalDateTime.now());
        return spPlService.save(spPl);
    }


    @PostMapping("/update")
    public Boolean update(@RequestBody SpPl spPl) {
        return spPlService.updateById(spPl);
    }


    @RequestMapping("/like")
    public List<SpPl> selectList(SpPl id) {
        List<SpPl> list = spPlService.selectList(id);
        return list;
    }

}
